// 路由-相关模块
import Vue from 'vue'
import VueRouter from 'vue-router'

import Layout from '@/views/Layout'
import Home from '@/views/Home'
import Search from '@/views/Search'

// 1、vue使用 vuerouter
Vue.use(VueRouter)
// 2、定义路由匹配规则
const routes = [
    {
        path: '/',
        redirect: '/layout',
    },
    {
        path: '/layout',
        component: Layout,
        redirect: '/layout/home',
        children: [
            {
                path: 'home',
                component: Home,
                meta: {
                    title: '首页',
                },
            },
            {
                path: 'search',
                component: Search,
                meta: {
                    title: '搜索',
                },
            },
        ],
    },
]
// 3、创建路由实例对象
const router = new VueRouter({
    routes,
})
// 4、对外导出路由实例对象
export default router
